package com.lemei.cn.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lemei.cn.adpter.MyRecycleViewAdpter;
import com.lemei.cn.lemeiapp.R;
import com.lemei.cn.utils.ToastMake;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 赵航 on 2017/5/27.
 */

public class BuHuo extends BaisFragment {


    private View mView;
    private RecyclerView mRecyclerView;
    private int[]         brr   = {R.mipmap.a,R.mipmap.bacground,R.mipmap.cang,R.mipmap.h,R.mipmap.hus,R.mipmap.r,R.mipmap.s,R.mipmap.v,R.mipmap.w,R.mipmap.x,R.mipmap.y,R.mipmap.z,R.mipmap.zhufu};
    private List<Integer> mList = new ArrayList<>();

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
       // View view = LayoutInflater.fromgetContext()).inflate(R.layout.buhuo,container ,false);

        mView = View.inflate(getContext(), R.layout.buhuo, null);


        return mView;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        mRecyclerView = (RecyclerView) mView.findViewById(R.id.mian_recycleerview);

//最后的判断是方向
       // RecyclerView.LayoutManager manager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, true);

        //多排
        RecyclerView.LayoutManager manager = new GridLayoutManager(getContext(), 3,GridLayoutManager.VERTICAL,false);

        //瀑布流
        RecyclerView.LayoutManager manager1 = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);

        mRecyclerView.setLayoutManager(manager1);
        MyRecycleViewAdpter adpter = new MyRecycleViewAdpter(mList);
        mRecyclerView.setAdapter(adpter);
        adpter.setOnPagerClikeListen(new MyRecycleViewAdpter.OnPagerClikeListen() {
            @Override
            public void onPageClike(int postion) {
               // 点击条目事件

                ToastMake.showToast(postion+"");
            }
        });


    }

    @Override
    public void onResume() {
        super.onResume();

        for (int i : brr) {
            mList.add(i);
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        if (mList!=null)
        mList.clear();
    }
}
